package com.winsdom.controller.CustomerManagementController;

import com.winsdom.anno.Authentication;
import com.winsdom.annotation.OperationLog;
import com.winsdom.result.Result;
import com.winsdom.service.ResourceInfoService;
import com.winsdom.vo.ResourceInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.winsdom.enums.AuthenticationType.CUSTOMER_MANAGEMENT;

/**
 * 资源信息控制器
 * 用于管理客户关联的资源信息，包括查询客户已迁入的资源信息
 * 支持查询房屋、车位等资源类型的信息
 */
@Slf4j
@RestController
@RequestMapping("/resource-info")
@Api(tags = "客户管理接口", description = "客户资源信息管理接口")
@Authentication(value=CUSTOMER_MANAGEMENT)
public class ResourceInfoController {

    @Autowired
    private ResourceInfoService resourceInfoService;

    @GetMapping("/customer/{customerId}")
    @ApiOperation(value = "查询客户已迁入的资源信息", notes = "根据客户ID查询其已迁入的资源信息，包括房屋、车位等")
    @OperationLog(description = "查询客户已迁入的资源信息")
    public Result<List<ResourceInfoVO>> getResourceInfoByCustomerId(@PathVariable Long customerId) {
        log.info("查询客户已迁入的资源信息，客户ID：{}", customerId);
        List<ResourceInfoVO> resourceInfoList = resourceInfoService.getResourceInfoByCustomerId(customerId);
        return Result.success(resourceInfoList);
    }
}